<div id="map_canvas"></div>
<!--hide customer address
<h2>Customer Address</h2>
		<?
			$i=0;
			foreach($dataList as $in=>$val){
				//print_r($val);exit();
		?>
			<div class="addresDisplay" id="resultText<?php echo $i?>">
				<img src="<?php echo $image?>ajax-loader.gif" /> 
				waiting for progress </div>
		<?
				$i++;
			}
		?> 
-->
<style type="text/css">
	div#map_canvas {
		margin: auto;
		width: 100%;
		height: 450px;
		overflow: hidden;
		padding: 20px;
	}
</style>
<script type='text/javascript' src="http://maps.googleapis.com/maps/api/js?sensor=false&extension=.js&output=embed"></script>

<!-- JavaScript jQuery code from Bootply.com editor  -->

<script type='text/javascript'>var custLocation =<?php echo json_encode($dataList)?>;
	var objLength =  <?php echo count($dataList)?>;
	var marker;
	var address = new Array();
	$(document).ready(function() {

		function initialize() {
			var mapProp = {
				center : new google.maps.LatLng(13.723419, 100.476232),
				zoom : 10,
				draggable : true,
				scrollwheel : true,
				mapTypeId : google.maps.MapTypeId.ROADMAP
			};

		
			var map = new google.maps.Map(document.getElementById("map_canvas"), mapProp);
			
			<?
			$i=0;
			$j = 0;
			$start = 0;
			$max = 3;
			foreach($dataList as $in=>$val){
				//print_r($val);exit();
			?>
			
				
				var myCenter<?php echo $i?> = new google.maps.LatLng(<?php echo $val->Latitude?>,<?php echo $val->Longitude?>);
				var marker<?php echo $i?> = new google.maps.Marker({
					position : myCenter<?php echo $i?>
				});
				
				marker<?php echo $i?>.setMap(map);
				google.maps.event.addListener(marker<?php echo $i?>, 'click', function() {
					
					marker<?php echo $i?>.info = new google.maps.InfoWindow({
						<?
							$v = trim(preg_replace('/\s+/', ' ', $val->ADDRESS));
							$display = ($v=="") ? 'address['.$i.']' : $v;
						?>
						content: address[<?php echo $i?>]
					});
					marker<?php echo $i?>.info.open(map, marker<?php echo $i?>);
				});
				<?
				
				if($i % $max == 0  ){
					
					
				?>
					setTimeout(function(){
				
				<?
				}
				?>
				var geocoder<?php echo $i?> = new google.maps.Geocoder();
				
				geocoder<?php echo $i?>.geocode({ 'latLng': new google.maps.LatLng(<?php echo $val->Latitude?>,<?php echo $val->Longitude?>) }
					, function(results, status){
	    				if (status == google.maps.GeocoderStatus.OK) {
	    					address[<?php echo $i?>] = results[0].formatted_address; 
							$('#resultText<?php echo $i?>').html("<?php echo $val->KUNNR?>: "+results[0].formatted_address+"<br />");
						}else{
							alert('Geocode was not successful for the following reason: ' + status);
						}
					}
				);
				
				<?
				
				if($i % $max == 0  ){
					$start++;
				?>
				},<?php echo $start * 2000?>);
				
				<?
				}
				?>
			<?
			
			$i++;
				
			}
			?>
		};
		initialize();

	});
	function ObjectLength(object) {
		var length = 0;
		for (var key in object ) {
			if (object.hasOwnProperty(key)) {++length;
			}
		}
		return length;
	};

</script>
<script type="text/javascript"></script>

